<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/10/25 0025
 * Time: 11:14
 */

namespace app\admin\controller;


use think\Controller;
use think\facade\Session;

class Login extends Controller
{
    public function login(){
        return view("login");
    }
    public function doLogin(){
        $param = request()->param();
        if(empty($param['username']) || empty($param['password'])){
            $this->error("哎呦卧槽~~~账号或密码不能为空","/admin/login/login");
        }
        $data = db("admin")->where("username",$param['username'])->find();
        if(empty($data)){
            $this->error("哎呦卧槽~~~用户不存在","/admin/login/login");
        }
        if($data['password'] != $param['password']){
            $this->error("哎呦卧槽~~~账号或密码输入错误","/admin/login/login");
        }
        Session::set("sess_admin_id",$data['id']);
        $this->success("哎呦卧槽~~~这次正确咯","/admin/index/index");
    }
}